package cn.stylefeng.guns.modular.business.frequency.siterelation.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.business.frequency.siterelation.service.SiteRelationService;
import cn.stylefeng.guns.modular.business.frequency.siterelation.model.param.SiteRelationParam;

import javax.annotation.Resource;

/**
 * 网点人员关联表 控制器
 *
 * @author: yujie
 * @date: 2023/05/10 16:16
 */
@RestController
public class BranchRelationController {

    @Resource
    private SiteRelationService branchRelationService;

    /**
     * 分页查询网点人员关联表
     *
     * @author yujie
     * @date 2023/05/10 16:16
     */
    @GetMapping("/branchRelation/page")
    @BusinessLog(title = "网点人员关联表_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(SiteRelationParam siteRelationParam) {
        return new SuccessResponseData(branchRelationService.page(siteRelationParam));
    }

    /**
     * 获取全部网点人员关联表
     *
     * @author yujie
     * @date 2023/05/10 16:16
     */
    @GetMapping("/branchRelation/list")
    @BusinessLog(title = "网点人员关联表_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(SiteRelationParam siteRelationParam) {
        return new SuccessResponseData(branchRelationService.list(siteRelationParam));
    }

    @PostMapping("/branchRelation/bindUser")
    @BusinessLog(title = "用户绑定网点", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData bindUser(@RequestBody SiteRelationParam siteRelationParam) {
        return branchRelationService.bindUser(siteRelationParam);
    }

    /**
     * 查看详情网点人员关联表
     *
     * @author yujie
     * @date 2023/05/10 16:16
     */
    @GetMapping("/branchRelation/detail")
    @BusinessLog(title = "网点人员关联表_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(SiteRelationParam.detail.class) SiteRelationParam siteRelationParam) {
        return new SuccessResponseData(branchRelationService.detail(siteRelationParam));
    }

    /**
     * 添加网点人员关联表
     *
     * @author yujie
     * @date 2023/05/10 16:16
     */
    @PostMapping("/branchRelation/add")
    @BusinessLog(title = "网点人员关联表_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(SiteRelationParam.add.class) SiteRelationParam siteRelationParam) {
        branchRelationService.add(siteRelationParam);
        return new SuccessResponseData();
    }

    /**
     * 删除网点人员关联表
     *
     * @author yujie
     * @date 2023/05/10 16:16
     */
    @PostMapping("/branchRelation/delete")
    @BusinessLog(title = "网点人员关联表_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(SiteRelationParam.delete.class) SiteRelationParam siteRelationParam) {
        branchRelationService.delete(siteRelationParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑网点人员关联表
     *
     * @author yujie
     * @date 2023/05/10 16:16
     */
    @PostMapping("/branchRelation/edit")
    @BusinessLog(title = "网点人员关联表_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(SiteRelationParam.edit.class) SiteRelationParam siteRelationParam) {
        branchRelationService.edit(siteRelationParam);
        return new SuccessResponseData();
    }


}
